<template>
	<view>
		<view class="title">
			智慧城市
		</view>
		<view class="main">
			<u-form :model="form" label-width="160">
				<u-form-item label="用户名">
					<u-input v-model="form.username"></u-input>
				</u-form-item>
				<u-form-item label="密码">
					<u-input type="password" v-model="form.password"></u-input>
				</u-form-item>
			</u-form>
			<navigator url="/pages/register/register" class="register">
				<text>没有账号?点击这里注册</text>
			</navigator>
		</view>
		<button @click="submit">登录</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					username: '',
					password: ''
				}
			};
		},
		methods: {
			submit(){
				// this.$request({
				// 	url: '/prod-api/api/login',
				// 	methods: 'POST',
				// 	data: {
				// 		...this.form
				// 	}
				// }).then(res => {
				// 	if(res.code === 200){
				// 		uni.showToast({
				// 			title:'登录成功'
				// 		})
				// 		setTimeout(() => {
				// 			uni.reLaunch({
				// 				url:'/pages/index/index'
				// 			})
				// 		}, 1000)
				// 	}else{
				// 		uni.showToast({
				// 			icon:'error',
				// 			title:res.msg
				// 		})
				// 	}
				// })
				uni.request({
					url:this.$baseUrl + 'http://124.93.196.45:10001/',
					method: 'POST',
					data: {
						...this.form
					},
					success: (res) => {
						console.log(res)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
view{
	padding: 20rpx;
	.title{
		padding: 20rpx;
		color: #2979ff;
		font-size: 45rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.register{
		display: flex;
		justify-content: end;
		color: #2979ff;
		font-size: 26rpx;
	}
	button{
		width: 200rpx;
		height: 80rpx;
		background-color: #2979ff;
		color: white;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 50rpx;
	}
}
</style>
